home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 4.1 KB | 159 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPriDeb.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWENVDEF_H
- #include "FWEnvDef.h"
- #endif
-
- #if !defined(FWPRIDEB_H) && defined(FW_DEBUG)
- #define FWPRIDEB_H
-
- #ifndef FWDBGSTR_H
- #include "FWDbgStr.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- class FW_CLASS_ATTR FW_CDebugConsole
- {
- public:
-
- virtual ~FW_CDebugConsole();
- // Destructor, does nothing.
-
- FW_CDebugConsole();
- // Constructor, does SetConsole(0).
-
- static FW_CDebugConsole* GetConsole();
- // Get the currently installed debug console
-
- static FW_CDebugConsole* SetConsole(FW_CDebugConsole* console);
- // Install a new debug console.
- // The prior debug console is returned.
-
- static void LogMessage(const char* message);
- // Display the message, preferably without suspending execution.
-
- static void DebugMessage(const char* message);
- // Suspend normal execution and display the message.
-
- static void Debugger();
- // Suspend normal execution without displaying a message
-
- FW_CDebugStream & GetFatalErrorStream();
- // Get the fatal error stream
-
- FW_CDebugStream & GetWarningStream();
- // Get the warning stream
-
- FW_CDebugStream & GetNotificationStream();
- // Get the notification stream
-
- protected:
-
- virtual void DoLogMessage(const char* message);
- // Display the message, preferably without suspending execution.
-
- virtual void DoDebugMessage(const char* message);
- // Suspend normal execution and display the message.
-
- virtual void DoDebugger();
- // Suspend normal execution without displaying a message
-
- FW_CDebugStream * fFatalErrorStream;
- // Stream for fatal error messages
-
- FW_CDebugStream * fWarningStream;
- // Stream for warning messages
-
- FW_CDebugStream * fNotificationStream;
- // Stream for notification messages
-
- public:
-
- // ----- Internal Methods
-
- static void PrivDebugMessage(const char* message);
- // Hard drop into debugger and display the message.
-
- static void PrivDebugger();
- // Hard drop into debugger without displaying a message
-
- private:
- enum { kBufferSize = 100};
- // Size of the buffer for the debug stream
-
- char fBuffer[100];
- // The debug stream buffer
-
- FW_CBufferDebugStream fBufferStream;
- // Buffer stream
-
- FW_CNullDebugStream fNullStream;
- // Null stream
-
- static FW_CDebugConsole *gDebugConsole;
- static FW_CDebugConsole sDebugConsole;
- // Where to write
-
- FW_CDebugConsole(const FW_CDebugConsole& debugConsole);
- FW_CDebugConsole& operator=(const FW_CDebugConsole& debugConsole);
- // Don't copy instances of this class.
- };
-
- #define FW_PRIV_DEBUGGER_BREAK() FW_CDebugConsole::PrivDebugger()
-
- #define FW_PRIV_DEBUGGER_STRING(message) FW_CDebugConsole::PrivDebugMessage(message)
-
- #define FW_PRIV_ASSERT(f) if(!(f)) FW_CDebugConsole::PrivDebugMessage((const char*) #f)
- // If f evaluates to false, drop into the debugger and display f as string.
-
- #define FW_DEBUGGER() FW_CDebugConsole::Debugger()
-
- #define FW_DEBUG_MESSAGE(message) FW_CDebugConsole::DebugMessage(message)
-
- #define FW_LOG_MESSAGE(message) FW_CDebugConsole::LogMessage(message)
-
- #define FW_ASSERT(f) if(!(f)) FW_CDebugConsole::DebugMessage((const char*) #f)
- //#define FW_ASSERT(f) if(!(f)) FW_CDebugConsole::DebugMessage((const char*) #f)
- // If f evaluates to false, drop into the debug console and display f as string.
-
- inline FW_CDebugStream & FW_CDebugConsole::GetFatalErrorStream()
- {
- return *fFatalErrorStream;
- }
-
- inline FW_CDebugStream & FW_CDebugConsole::GetWarningStream()
- {
- return *fWarningStream;
- }
-
- inline FW_CDebugStream & FW_CDebugConsole::GetNotificationStream()
- {
- return *fNotificationStream;
- }
-
- #else
-
- #define FW_PRIV_DEBUGGER_BREAK() ((void)0)
- #define FW_PRIV_DEBUGGER_STRING(message) ((void)0)
- #define FW_PRIV_ASSERT(f) ((void)0)
- #define FW_DEBUGGER() ((void)0)
- #define FW_DEBUG_MESSAGE(message) ((void)0)
- #define FW_LOG_MESSAGE(message) ((void)0)
- #define FW_ASSERT(f) ((void)0)
-
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-